package siga.visao_financeiro;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.navegadores.navegador;
import siga.pacotao.contadorData;
import siga.visao.index;
import siga.visao.verErros;

/**
 *
 * @author rafaelfrasson
 */
public class movNegociar extends javax.swing.JDialog {
    
    List cod_parcela = new ArrayList();
    public static boolean finalizar = false;
    Object[] JOopcoes = {"Sim","Não"};

    public movNegociar(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpPrincipalMN = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtMesalidade2 = new javax.swing.JTable();
        jToolBar3 = new javax.swing.JToolBar();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jtfSaldoBruto = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfJuros = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfSaldoNeg = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfSaldoEntrada = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtfLiqNeg = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jToolBar4 = new javax.swing.JToolBar();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jButton22 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jtfJurosP = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jtfTurma = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jtfDescLiq = new javax.swing.JTextField();
        jtfDescLiqTipo = new javax.swing.JComboBox();
        jToolBar5 = new javax.swing.JToolBar();
        jButton27 = new javax.swing.JButton();
        jButton28 = new javax.swing.JButton();
        jtfObs = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jtNegociacao = new javax.swing.JTable();
        jtfQtdParc = new javax.swing.JTextField();
        jtfDataIni = new javax.swing.JFormattedTextField();
        jLabel16 = new javax.swing.JLabel();
        jtfVlTotal = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jtfVlJuro = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jtfVlLiq = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jtfFase = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Negociação");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jpPrincipalMN.setName("jpPrincipalMN"); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mensalidades", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("SansSerif", 0, 11))); // NOI18N
        jPanel4.setFont(new java.awt.Font("SansSerif", 0, 11));
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jtMesalidade2.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtMesalidade2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Parc", "Vencimento", "Saldo", "Situação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtMesalidade2.setName("jtMesalidade2"); // NOI18N
        jScrollPane3.setViewportView(jtMesalidade2);

        jToolBar3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jToolBar3.setFloatable(false);
        jToolBar3.setRollover(true);
        jToolBar3.setName("jToolBar3"); // NOI18N

        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/add_todos.png"))); // NOI18N
        jButton15.setToolTipText("Adicionar Mensalidades");
        jButton15.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jButton15.setFocusable(false);
        jButton15.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton15.setName("jButton15"); // NOI18N
        jButton15.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar3.add(jButton15);

        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_todos.png"))); // NOI18N
        jButton16.setToolTipText("Remover Mensalidades Selecionadas");
        jButton16.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jButton16.setFocusable(false);
        jButton16.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton16.setName("jButton16"); // NOI18N
        jButton16.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar3.add(jButton16);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
            .addComponent(jToolBar3, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Base de Cálculo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("SansSerif", 0, 11))); // NOI18N
        jPanel5.setFont(new java.awt.Font("SansSerif", 0, 11));
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel2.setText("Slado Bruto:");
        jLabel2.setName("jLabel2"); // NOI18N

        jtfSaldoBruto.setEditable(false);
        jtfSaldoBruto.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfSaldoBruto.setName("jtfSaldoBruto"); // NOI18N

        jLabel4.setText("Saldo Juros:");
        jLabel4.setName("jLabel4"); // NOI18N

        jtfJuros.setText("0,00");
        jtfJuros.setName("jtfJuros"); // NOI18N
        jtfJuros.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfJurosFocusLost(evt);
            }
        });
        jtfJuros.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfJurosKeyPressed(evt);
            }
        });

        jLabel5.setText("Saldo a Negociar:");
        jLabel5.setName("jLabel5"); // NOI18N

        jtfSaldoNeg.setEditable(false);
        jtfSaldoNeg.setName("jtfSaldoNeg"); // NOI18N

        jLabel6.setText("Valor de Entrada:");
        jLabel6.setName("jLabel6"); // NOI18N

        jtfSaldoEntrada.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfSaldoEntrada.setText("0,00");
        jtfSaldoEntrada.setName("jtfSaldoEntrada"); // NOI18N
        jtfSaldoEntrada.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfSaldoEntradaFocusLost(evt);
            }
        });
        jtfSaldoEntrada.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfSaldoEntradaKeyPressed(evt);
            }
        });

        jLabel7.setText("Liquido a Negociar:");
        jLabel7.setName("jLabel7"); // NOI18N

        jtfLiqNeg.setEditable(false);
        jtfLiqNeg.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfLiqNeg.setName("jtfLiqNeg"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfLiqNeg, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                    .addComponent(jtfSaldoBruto, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                    .addComponent(jtfJuros, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                    .addComponent(jtfSaldoNeg, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                    .addComponent(jtfSaldoEntrada, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE))
                .addGap(12, 12, 12))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfSaldoBruto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfJuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtfSaldoNeg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfSaldoEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfLiqNeg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Finalização do Negociação", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("SansSerif", 0, 11))); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jLabel8.setText("Quantidade de Parcelas:");
        jLabel8.setName("jLabel8"); // NOI18N

        jToolBar4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jToolBar4.setFloatable(false);
        jToolBar4.setRollover(true);
        jToolBar4.setName("jToolBar4"); // NOI18N

        jButton17.setText("x2");
        jButton17.setFocusable(false);
        jButton17.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton17.setName("jButton17"); // NOI18N
        jButton17.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton17);

        jButton18.setText("x4");
        jButton18.setFocusable(false);
        jButton18.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton18.setName("jButton18"); // NOI18N
        jButton18.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton18);

        jButton19.setText("x6");
        jButton19.setFocusable(false);
        jButton19.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton19.setName("jButton19"); // NOI18N
        jButton19.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton19);

        jButton20.setText("x12");
        jButton20.setFocusable(false);
        jButton20.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton20.setName("jButton20"); // NOI18N
        jButton20.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton20);

        jButton21.setText("x14");
        jButton21.setFocusable(false);
        jButton21.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton21.setName("jButton21"); // NOI18N
        jButton21.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton21);

        jButton22.setText("x16");
        jButton22.setFocusable(false);
        jButton22.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton22.setName("jButton22"); // NOI18N
        jButton22.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton22);

        jButton23.setText("x18");
        jButton23.setFocusable(false);
        jButton23.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton23.setName("jButton23"); // NOI18N
        jButton23.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton23ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton23);

        jButton24.setText("x20");
        jButton24.setFocusable(false);
        jButton24.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton24.setName("jButton24"); // NOI18N
        jButton24.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton24ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton24);

        jButton25.setText("x22");
        jButton25.setFocusable(false);
        jButton25.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton25.setName("jButton25"); // NOI18N
        jButton25.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton25ActionPerformed(evt);
            }
        });
        jToolBar4.add(jButton25);

        jLabel9.setText("Iniciar a partir da Data de:");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText("Juros:");
        jLabel10.setName("jLabel10"); // NOI18N

        jtfJurosP.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfJurosP.setText("0");
        jtfJurosP.setName("jtfJurosP"); // NOI18N
        jtfJurosP.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfJurosPFocusLost(evt);
            }
        });
        jtfJurosP.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfJurosPKeyTyped(evt);
            }
        });

        jLabel11.setText("%");
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setFont(new java.awt.Font("SansSerif", 0, 13));
        jLabel12.setText("Turma Selecionada:");
        jLabel12.setName("jLabel12"); // NOI18N

        jtfTurma.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfTurma.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Todos" }));
        jtfTurma.setName("jtfTurma"); // NOI18N

        jLabel13.setText("Título:");
        jLabel13.setName("jLabel13"); // NOI18N

        jComboBox2.setFont(new java.awt.Font("SansSerif", 0, 11));
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Negocição", "Cheque Devolvido", "Mensalidade", "Negociação Jurídico", "Nota Promissória a Receber", "Taxa de Material" }));
        jComboBox2.setName("jComboBox2"); // NOI18N

        jLabel14.setText("Observação:");
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setText("Desconto sobre o Liquido a Negociar:");
        jLabel15.setName("jLabel15"); // NOI18N

        jtfDescLiq.setText("0,00");
        jtfDescLiq.setName("jtfDescLiq"); // NOI18N
        jtfDescLiq.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfDescLiqFocusLost(evt);
            }
        });
        jtfDescLiq.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfDescLiqKeyTyped(evt);
            }
        });

        jtfDescLiqTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "$R", "%" }));
        jtfDescLiqTipo.setName("jtfDescLiqTipo"); // NOI18N
        jtfDescLiqTipo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfDescLiqTipoFocusLost(evt);
            }
        });

        jToolBar5.setBorder(javax.swing.BorderFactory.createCompoundBorder());
        jToolBar5.setFloatable(false);
        jToolBar5.setRollover(true);
        jToolBar5.setName("jToolBar5"); // NOI18N

        jButton27.setFont(new java.awt.Font("SansSerif", 0, 11));
        jButton27.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/finaliza_negociacao.png"))); // NOI18N
        jButton27.setText("Finalizar");
        jButton27.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jButton27.setFocusable(false);
        jButton27.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton27.setMargin(new java.awt.Insets(4, 14, 4, 14));
        jButton27.setName("jButton27"); // NOI18N
        jButton27.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton27ActionPerformed(evt);
            }
        });
        jToolBar5.add(jButton27);

        jButton28.setFont(new java.awt.Font("SansSerif", 0, 11));
        jButton28.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/sair_32x32.png"))); // NOI18N
        jButton28.setText("Cancelar");
        jButton28.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jButton28.setFocusable(false);
        jButton28.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton28.setName("jButton28"); // NOI18N
        jButton28.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton28ActionPerformed(evt);
            }
        });
        jToolBar5.add(jButton28);

        jtfObs.setName("jtfObs"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jtNegociacao.setFont(new java.awt.Font("SansSerif", 0, 12));
        jtNegociacao.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Parc", "Vencimento", "Vl. Bruto", "Vl. Juro", "Vl. Liquido"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtNegociacao.setName("jtNegociacao"); // NOI18N
        jScrollPane4.setViewportView(jtNegociacao);

        jtfQtdParc.setText("1");
        jtfQtdParc.setName("jtfQtdParc"); // NOI18N
        jtfQtdParc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfQtdParcFocusLost(evt);
            }
        });
        jtfQtdParc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtfQtdParcKeyTyped(evt);
            }
        });

        try {
            jtfDataIni.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDataIni.setName("jtfDataIni"); // NOI18N
        jtfDataIni.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jtfDataIniFocusLost(evt);
            }
        });

        jLabel16.setText("Valor Total:");
        jLabel16.setName("jLabel16"); // NOI18N

        jtfVlTotal.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfVlTotal.setText("0,00");
        jtfVlTotal.setName("jtfVlTotal"); // NOI18N

        jLabel17.setText("Valor Juro:");
        jLabel17.setName("jLabel17"); // NOI18N

        jtfVlJuro.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfVlJuro.setText("0,00");
        jtfVlJuro.setName("jtfVlJuro"); // NOI18N

        jLabel18.setText("Valor Liquido:");
        jLabel18.setName("jLabel18"); // NOI18N

        jtfVlLiq.setFont(new java.awt.Font("SansSerif", 0, 11));
        jtfVlLiq.setText("0,00");
        jtfVlLiq.setName("jtfVlLiq"); // NOI18N

        jLabel1.setText("Módulo/Fase/Bimestre:");
        jLabel1.setName("jLabel1"); // NOI18N

        jtfFase.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Todos" }));
        jtfFase.setName("jtfFase"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16)
                            .addComponent(jtfVlTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(29, 29, 29)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jtfVlJuro, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(25, 25, 25)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(jtfVlLiq, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(357, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 649, Short.MAX_VALUE)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfQtdParc, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jToolBar4, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfObs, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox2, 0, 593, Short.MAX_VALUE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfDataIni, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfJurosP, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtfTurma, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfFase, 0, 163, Short.MAX_VALUE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfDescLiq, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfDescLiqTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addComponent(jToolBar5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE)))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(jtfQtdParc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jToolBar4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtfDataIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jtfJurosP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jtfDescLiq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfDescLiqTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jtfTurma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jtfFase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfObs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfVlTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfVlJuro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfVlLiq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                .addComponent(jToolBar5, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout jpPrincipalMNLayout = new javax.swing.GroupLayout(jpPrincipalMN);
        jpPrincipalMN.setLayout(jpPrincipalMNLayout);
        jpPrincipalMNLayout.setHorizontalGroup(
            jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1147, Short.MAX_VALUE)
            .addGroup(jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jpPrincipalMNLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        jpPrincipalMNLayout.setVerticalGroup(
            jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 582, Short.MAX_VALUE)
            .addGroup(jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jpPrincipalMNLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jpPrincipalMNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jpPrincipalMNLayout.createSequentialGroup()
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPrincipalMN, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPrincipalMN, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtfJurosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfJurosFocusLost
        if(!jtfJuros.getText().equals("")){
            SaldoNeg();
            LiqNeg();
        }
}//GEN-LAST:event_jtfJurosFocusLost

    private void jtfJurosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfJurosKeyPressed
        if(!jtfJuros.getText().equals("")){
            SaldoNeg();
            LiqNeg();
        }
}//GEN-LAST:event_jtfJurosKeyPressed

    private void jtfSaldoEntradaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfSaldoEntradaFocusLost
        if(!jtfSaldoEntrada.getText().equals("")){
            LiqNeg();
        }
}//GEN-LAST:event_jtfSaldoEntradaFocusLost

    private void jtfSaldoEntradaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfSaldoEntradaKeyPressed
        if(!jtfSaldoEntrada.getText().equals("")){
            LiqNeg();
        }
}//GEN-LAST:event_jtfSaldoEntradaKeyPressed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        MostraQtdPerc(jButton17);
}//GEN-LAST:event_jButton17ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        MostraQtdPerc(jButton18);
}//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        MostraQtdPerc(jButton19);
}//GEN-LAST:event_jButton19ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
        MostraQtdPerc(jButton20);
}//GEN-LAST:event_jButton20ActionPerformed

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
        MostraQtdPerc(jButton21);
}//GEN-LAST:event_jButton21ActionPerformed

    private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
        MostraQtdPerc(jButton22);
}//GEN-LAST:event_jButton22ActionPerformed

    private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
        MostraQtdPerc(jButton23);
}//GEN-LAST:event_jButton23ActionPerformed

    private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
        MostraQtdPerc(jButton24);
}//GEN-LAST:event_jButton24ActionPerformed

    private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton25ActionPerformed
        MostraQtdPerc(jButton25);
}//GEN-LAST:event_jButton25ActionPerformed

    private void jtfJurosPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfJurosPFocusLost
        if(!jtfJurosP.getText().equals("")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfJurosPFocusLost

    private void jtfJurosPKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfJurosPKeyTyped
        if(!jtfJurosP.getText().equals("")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfJurosPKeyTyped

    private void jtfDescLiqFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfDescLiqFocusLost
        if(!jtfDescLiq.getText().equals("")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfDescLiqFocusLost

    private void jtfDescLiqKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescLiqKeyTyped
        if(!jtfDescLiq.getText().equals("")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfDescLiqKeyTyped

    private void jtfDescLiqTipoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfDescLiqTipoFocusLost
        calculaNegociacao();
}//GEN-LAST:event_jtfDescLiqTipoFocusLost

    private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton27ActionPerformed
        String data;
        for(int i=0;i<jtMesalidade2.getRowCount();i++){
            conexao.Inserir("delete from fin_contas_mov_r where cod_emp="+index.cod_emp+" and codigo="+cod_parcela.get(i));
        }
        for(int i=0;i<Integer.parseInt(jtfQtdParc.getText());i++){
            try {
                data = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(jtNegociacao.getValueAt(i, 1).toString()));
                conexao.Inserir("insert into fin_contas_mov_r (cod_emp,cod_plano_contas,cod_centro_custos,cod_matricula,cod_fase,cod_pessoa,parcela,descricao,dt_emissao,dt_vencimento,valor_bruto,status) " + "values (" + index.cod_emp + ",10924," + jtfTurma.getSelectedItem().toString().substring(0, 3) + ",'" + jtfTurma.getSelectedItem() + "'," + jtfFase.getSelectedItem() + "," + index.LRpessoa.get(0) + "," + (50 + i) + ",\"" + jtfObs.getText() + "\",now(),\"" + data + " 00:00:00\"," + index.ftes.parse(jtNegociacao.getValueAt(i, 4).toString()) + ",\"A Receber\")");
            } catch (ParseException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
        JOptionPane.showMessageDialog(null, "Negociação Concluída.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        finalizar=true;
        if (JOptionPane.showOptionDialog(null, "Deseja Imprimir o Contrato Agora?", "Impressão de Contrato", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
            navegador.URL("http://201.35.207.198/sistema/relatorios/relatorio_negociacao.php?cod_emp="+index.cod_emp+"&cod_matricula="+jtfTurma.getSelectedItem()+"&cod_pessoa="+index.LRpessoa.get(0)+"&cod_fase="+jtfFase.getSelectedItem());
        }
        dispose();
}//GEN-LAST:event_jButton27ActionPerformed

    private void jButton28ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton28ActionPerformed
        dispose();
}//GEN-LAST:event_jButton28ActionPerformed

    private void jtfQtdParcFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfQtdParcFocusLost
        calculaNegociacao();
}//GEN-LAST:event_jtfQtdParcFocusLost

    private void jtfQtdParcKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfQtdParcKeyTyped
        if(!jtfQtdParc.getText().equals("")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfQtdParcKeyTyped

    private void jtfDataIniFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtfDataIniFocusLost
        if(!jtfDataIni.getText().equals("  /  /    ")){
            calculaNegociacao();
        }
}//GEN-LAST:event_jtfDataIniFocusLost

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        String data;
        double slbrt=0;
        double juros=0;
        Date dtAgora = new Date();
        String turma="";
        String fase="";
        jtfDataIni.setText(index.dataAgoraBR);
        if(!index.LRpessoa.get(0).equals("")){
            try {
                conexao.Query("select * from fin_contas_mov_r where cod_pessoa=" + index.LRpessoa.get(0).toString() + " and cod_emp=" + index.cod_emp + " and (status='A Receber' or status='Parcial')");
                javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel) jtMesalidade2.getModel();
                int i = jtMesalidade2.getRowCount();
                for (int x = i - 1; x >= 0; --x) {
                    jtm.removeRow(x);
                }
                jtfTurma.removeAllItems();
                jtfFase.removeAllItems();
                while (conexao.rs.next()) {
                    if (conexao.rs.getDate("dt_vencimento").before(dtAgora)) {
                        cod_parcela.add(conexao.rs.getString("codigo"));
                        data = new SimpleDateFormat("dd/MM/yyyy").format(conexao.rs.getDate("dt_vencimento"));
                        double resData = (conexao.rs.getTimestamp("dt_vencimento") != null) ? ((dtAgora.getTime() - conexao.rs.getTimestamp("dt_vencimento").getTime()) / 86400000L) : 0.00;
                        slbrt += conexao.rs.getDouble("valor_bruto");
                        juros += (((conexao.rs.getDouble("valor_bruto") * 0.01) / 30) * resData) + (conexao.rs.getDouble("valor_bruto") * 0.02);
                        jtm.addRow(new Object[]{conexao.rs.getString("parcela"), data, index.ftbr.format(conexao.rs.getDouble("valor_bruto")), conexao.rs.getString("status")});

                        if(!conexao.rs.getString("cod_matricula").equals(turma)){
                            jtfTurma.addItem(conexao.rs.getString("cod_matricula"));
                            turma=conexao.rs.getString("cod_matricula");
                        }
                        if(!conexao.rs.getString("cod_fase").equals(fase)){
                            jtfFase.addItem(conexao.rs.getString("cod_fase"));
                            fase=conexao.rs.getString("cod_fase");
                        }
                    }
                }
                jtfSaldoBruto.setText(index.ftbr.format(slbrt));
                jtfJuros.setText(index.ftbr.format(juros));
                slbrt += juros;
                jtfSaldoNeg.setText(index.ftbr.format(slbrt));
                jtfLiqNeg.setText(index.ftbr.format(slbrt));
                jtMesalidade2.selectAll();
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
        }else{
            JOptionPane.showMessageDialog(null, "Não foi possível identificar uma pessoa selecionada.","Erro do Sistema.",JOptionPane.ERROR_MESSAGE);
            dispose();
        }
    }//GEN-LAST:event_formWindowOpened

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed

    }//GEN-LAST:event_formWindowClosed

    private void LiqNeg(){
        try {
            double saldo = index.ftes.parse(jtfSaldoNeg.getText()).doubleValue() - index.ftes.parse(jtfSaldoEntrada.getText()).doubleValue();
            jtfLiqNeg.setText(index.ftbr.format(saldo));
        } catch (ParseException ex) {
            verErros.setErro(ex.getMessage());
        }
    }
    private void SaldoNeg(){
        try {
            double saldo = index.ftes.parse(jtfSaldoBruto.getText()).doubleValue() + index.ftes.parse(jtfJuros.getText()).doubleValue();
            jtfSaldoNeg.setText(index.ftbr.format(saldo));
        } catch (ParseException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void MostraQtdPerc(JButton obj){
        jtfQtdParc.setText(obj.getText().substring(1,obj.getText().length()));
        calculaNegociacao();
    }

    private void calculaNegociacao(){
        try {
            double vlbruto = 0;
            double vlparcela = 0;
            double vljuro = 0;
            double totbruto = 0;
            double totliq = 0;
            double totjuro = 0;
            String data = jtfDataIni.getText();
            vlbruto = index.ftes.parse(jtfSaldoBruto.getText()).doubleValue() / Double.parseDouble(jtfQtdParc.getText());
            vljuro = index.ftes.parse(jtfJuros.getText()).doubleValue() / Double.parseDouble(jtfQtdParc.getText());
            vlparcela = index.ftes.parse(jtfLiqNeg.getText()).doubleValue() / Double.parseDouble(jtfQtdParc.getText());
            if (Integer.parseInt(jtfJurosP.getText()) != 0) {
                vlparcela = vlparcela + (vlparcela * (index.ftes.parse(jtfJurosP.getText()).doubleValue() / 100));
            }
            if(jtfDescLiqTipo.getSelectedItem().toString().equals("$R")){
                vlparcela = vlparcela - index.ftes.parse(jtfDescLiq.getText()).doubleValue();
            }else if(jtfDescLiqTipo.getSelectedItem().toString().equals("%")){
                vlparcela = vlparcela - ((index.ftes.parse(jtfDescLiq.getText()).intValue()*vlparcela)/100);
            }
            contadorData.setDataSomaMes(data, "BR");
            javax.swing.table.DefaultTableModel jtn = (javax.swing.table.DefaultTableModel) jtNegociacao.getModel();
            int y = jtNegociacao.getRowCount();
            for (int x = y - 1; x >= 0; --x) {
                jtn.removeRow(x);
            }
            for (int i = 0; i < Integer.parseInt(jtfQtdParc.getText()); i++) {
                totbruto += vlbruto;
                totjuro += vljuro;
                totliq += vlparcela;
                jtn.addRow(new Object[]{i + 50, data, index.ftbr.format(vlbruto).toString(), index.ftbr.format(vljuro).toString(), index.ftbr.format(vlparcela).toString()});
                data = contadorData.getDataSomaMes();
            }
            jtfVlTotal.setText(index.ftbr.format(totbruto));
            jtfVlJuro.setText(index.ftbr.format(totjuro));
            jtfVlLiq.setText(index.ftbr.format(totliq));
        } catch (ParseException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton27;
    private javax.swing.JButton jButton28;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JToolBar jToolBar3;
    private javax.swing.JToolBar jToolBar4;
    private javax.swing.JToolBar jToolBar5;
    private javax.swing.JPanel jpPrincipalMN;
    private javax.swing.JTable jtMesalidade2;
    private javax.swing.JTable jtNegociacao;
    private javax.swing.JFormattedTextField jtfDataIni;
    private javax.swing.JTextField jtfDescLiq;
    private javax.swing.JComboBox jtfDescLiqTipo;
    private javax.swing.JComboBox jtfFase;
    private javax.swing.JTextField jtfJuros;
    private javax.swing.JTextField jtfJurosP;
    private javax.swing.JTextField jtfLiqNeg;
    private javax.swing.JTextField jtfObs;
    private javax.swing.JTextField jtfQtdParc;
    private javax.swing.JTextField jtfSaldoBruto;
    private javax.swing.JTextField jtfSaldoEntrada;
    private javax.swing.JTextField jtfSaldoNeg;
    private javax.swing.JComboBox jtfTurma;
    private javax.swing.JTextField jtfVlJuro;
    private javax.swing.JTextField jtfVlLiq;
    private javax.swing.JTextField jtfVlTotal;
    // End of variables declaration//GEN-END:variables

}
